<?php

namespace app\api\controller;


use app\common\model\Manager;
use app\common\model\Wenjuan as WenjuanModel;
use app\common\model\WenjuanFankui;

class Wenjuan extends Base
{


    public function __construct()
    {
        parent::__construct();
    }



    public function join()
    {
        $input = input('');
        if (request()->isPost()) {
            $time = time();
            $save = [
                'update_time' => $time,
                'create_time' => $time,
                'name' => $input['name'],
                'age' => $input['age'],
                'height' => $input['height'],
                'weight' => $input['weight'],
                'qiu_age' => $input['qiu_age'],
                'qingkuang' => $input['qingkuang'],
                'sport' => $input['sport'],
                'qidai' => $input['qidai'],
                'xingge' => implode(',',$input['xingge']),
                'address' => implode(',',$input['address']),
                'uid' => $this->uid
            ];
            WenjuanModel::setInsertGetId($save);
        }
        return returnJson(200, '提交成功');
    }

    public function fankui(){
        $wenjuan = WenjuanModel::getOne(['uid'=>$this->uid,'status'=>['>=',2]],'*','id desc');
        if($wenjuan){
            $fankui = WenjuanFankui::getOne(['wid'=>$wenjuan['id']]);
            $fankui['manager_name'] = Manager::getValue(['id'=>$fankui['mid']],'name');
            $wenjuan['fankui'] = $fankui;
            return returnJson(200, '提交成功',$wenjuan);
        }

        return returnJson(202, '没有反馈信息');
    }

    public function is_fankui(){
        $isfankui = WenjuanModel::getValue(['uid'=>['eq',$this->uid],'status'=>['>=',2]],'id')?true:false;
        return returnJson(200, '提交成功',$isfankui);
    }

}

